package com.guigu.controller.lq.controller;

import com.guigu.controller.lq.pojo.*;
import com.guigu.controller.lq.service.*;
import com.guigu.pojo.Vip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LqPsychologyController {
    @Autowired
    LqPsychologyjgService lqPsychologyjgService;
    @Autowired
    LqPsychologyService lqPsychologyService;
    @Autowired
    LqPsychologywtService lqPsychologywtService;
    @Autowired
    LqVipSetvice lqVipSetvice;
    @Autowired
    LqXldfService lqXldfService;
    String vipid;
    Integer id;
    @RequestMapping("/xljg")
    public PageVO<LqPsychologyjg> find(@RequestBody PageVO pageVO){
        PageVO<LqPsychologyjg> all = lqPsychologyjgService.find(pageVO.getPage(), pageVO.getNum(), pageVO.getVipname());
        return all;
    }

    @RequestMapping("/wt")
    public List<LqPsychologywt> findwt(){
        List<LqPsychologywt> findwt = lqPsychologywtService.findwt();
        return findwt;
    }
    @RequestMapping("/xbyid")
    public Vip byid(@RequestBody Vip lqVip){
        Vip byid = lqVipSetvice.byid(lqVip.getVipid());
        return byid;
    }
    @RequestMapping("/xlx")
    public List<LqPsychology> cxxlx(){
        List<LqPsychology> cxtlx = lqPsychologyService.cxxlx();
        return cxtlx;
    }

    @RequestMapping("/xadd")
    public int xladd(@RequestBody LqPsychologyjg lqPsychologyjg){

        int xladd = lqPsychologyjgService.xladd(lqPsychologyjg);
        vipid=lqPsychologyjg.getVipid();
        id=lqPsychologyjg.getId();
        return xladd;
    }
    @RequestMapping("/xlfs")
    public int xlfs(@RequestBody String [] aa){
        LqXldf lqXldf = new LqXldf();
        for(int i=0;i<aa.length;i++){
            if(i%4==0)
               lqXldf.setQpzfs(Integer.valueOf(aa[i]));
                lqXldf.setJlzfs(Integer.valueOf(aa[i]));
                lqXldf.setKbzfs(Integer.valueOf(aa[i]));
                lqXldf.setRjgxfs(Integer.valueOf(aa[i]));
                lqXldf.setVipid(vipid);
                lqXldf.setXid(id);
            lqXldfService.xlfs(lqXldf);
        }
        return   1;
    }
    @RequestMapping("/xlupid")
    public LqPsychologyjg selid(@RequestBody LqPsychologyjg lqPsychologyjg){
        LqPsychologyjg selid = lqPsychologyjgService.selid(lqPsychologyjg.getId());
        return selid;
    }
    @RequestMapping("/xlup")
    public int xlup(@RequestBody LqPsychologyjg lqPsychologyjg){
        int xlup = lqPsychologyjgService.xlup(lqPsychologyjg);
        return xlup;
    }
    @RequestMapping("/xldel")
    public int lxdel(@RequestBody LqPsychologyjg lqPsychologyjg){
        int xldel = lqPsychologyjgService.xldel(lqPsychologyjg.getId());
        return xldel;
    }
    @RequestMapping("/upxlfs")
    public int upxlfs(@RequestBody String [] aa){
        List<LqXldf> findxls = lqXldfService.findxls(vipid);
        LqXldf lqXldf = new LqXldf();
        for(int i=0;i<aa.length;i++) {
            if (i % 4 == 0)
                lqXldf.setQpzfs(Integer.valueOf(aa[i]));
            lqXldf.setJlzfs(Integer.valueOf(aa[i]));
            lqXldf.setKbzfs(Integer.valueOf(aa[i]));
            lqXldf.setRjgxfs(Integer.valueOf(aa[i]));
            lqXldf.setVipid(vipid);
            lqXldf.setXid(id);
            lqXldf.setId(findxls.get(0).getId());
            lqXldfService.upxl(lqXldf);
        }
        return 1;
    }
    @RequestMapping("/xfs")
    public List<LqXldf>tfs(@RequestBody LqXldf lqXldf){
        List<LqXldf> selfs = lqXldfService.selfs(lqXldf.getXid());
        return selfs;
    }
}
